#ifndef Polar_h__
#define Polar_h__



//===============================================================
//
//	Polar3
//
//===============================================================

namespace inf {
    class Vec3;

    class Polar3 {
    public:	
        float			radius, theta, phi;

        Polar3( void );
        explicit Polar3( const float radius, const float theta, const float phi );

        void 			set( const float radius, const float theta, const float phi );

        float			operator[]( const int index ) const;
        float &			operator[]( const int index );
        Polar3		    operator-() const;
        Polar3 &		operator=( const Polar3 &a );

        Vec3			to_Vec3( void ) const;
    };

    INF_INLINE Polar3::Polar3( void ) {
    }

    INF_INLINE Polar3::Polar3( const float radius, const float theta, const float phi ) {
        assert( radius > 0 );
        this->radius = radius;
        this->theta = theta;
        this->phi = phi;
    }

    INF_INLINE void Polar3::set( const float radius, const float theta, const float phi ) {
        assert( radius > 0 );
        this->radius = radius;
        this->theta = theta;
        this->phi = phi;
    }

    INF_INLINE float Polar3::operator[]( const int index ) const {
        return ( &radius )[ index ];
    }

    INF_INLINE float &Polar3::operator[]( const int index ) {
        return ( &radius )[ index ];
    }

    INF_INLINE Polar3 Polar3::operator-( void ) const {
        return Polar3( radius, -theta, -phi );
    }

    INF_INLINE Polar3 &Polar3::operator=( const Polar3 &a ) { 
        radius = a.radius;
        theta = a.theta;
        phi = a.phi;
        return *this;
    }

    INF_INLINE Vec3 Polar3::to_Vec3( void ) const {
        float sp, cp, st, ct;
        math::sincos( phi, sp, cp );
        math::sincos( theta, st, ct );
        return Vec3( cp * radius * ct, cp * radius * st, radius * sp );
    }


}   // ::inf

#endif // Polar_h__
